package com.zhuiYun.project.api.homepagefunction.limitedtimepurchase.service.impl;
import com.zhuiYun.project.api.appletshoppingcart.mapper.AppletShoppingCartMapper;
import com.zhuiYun.project.api.commoditycomment.entity.CommodityComment;
import com.zhuiYun.project.api.commoditycomment.mapper.CommodityCommentMapper;
import com.zhuiYun.project.api.homepagefunction.limitedtimepurchase.service.LimitedTimePurchaseService;
import com.zhuiYun.project.api.seckill.entity.SeckillDto;
import com.zhuiYun.project.api.seckill.mapper.SeckillDtoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
 * @ClassName LimitedtimePurchaseServiceImpl
 * @Description 限时抢购服务层
 * @Author lzk
 * @Date 2023/4/5 9:32
 **/
@Service
public class LimitedtimePurchaseServiceImpl implements LimitedTimePurchaseService {
    @Autowired
    SeckillDtoMapper seckillDtoMapper;
    @Autowired
    CommodityCommentMapper commodityCommentMapper;
    @Autowired
    AppletShoppingCartMapper appletShoppingCartMapper;
    /**
     * @Author lzk
     * @Description 限时抢购查询秒杀表中商品信息
     * @date 2023/4/5 9:42
     * Return java.util.List<com.zhuiYun.project.api.commoditydetail.entity.Commodity>
     */
    @Override
    public List<SeckillDto> queryFlashKillInformation(String commodityName) {
        List<SeckillDto> list = seckillDtoMapper.queryFlashKillInformation(commodityName);
        return list;
    }
    /**
     * @Author lzk
     * @Description 根据id查询秒杀商品信息
     * @date 2023/4/6 13:50
     * Return com.zhuiYun.project.api.seckill.entity.SeckillDto
     */
    @Override
    public SeckillDto getSeckillListById(Integer id) {
        SeckillDto list = seckillDtoMapper.getSeckillListById(id);
        Date seckillEndDate = list.getSeckillEndDate();
        long time = seckillEndDate.getTime();
        list.setSeckillDate(time);
        return list;
    }
    /**
     *
     * @Author lzk
     * @Description 计算评论总数量
     * @date 2023/4/7 11:24
     * Return com.zhuiYun.project.api.commoditycomment.entity.CommodityComment
     * @param cid
     */
    @Override
    public CommodityComment calculateTheTotalNumberOfComments(Integer cid) {
        CommodityComment commodityComment = commodityCommentMapper.calculateTheTotalNumberOfComments(cid);
        return commodityComment;
    }
    /**
     *
     * @Author lzk
     * @Description 查询所有评论
     * @date 2023/4/7 12:00
     * Return java.util.List<com.zhuiYun.project.api.commoditycomment.entity.CommodityComment>
     * @param cid
     */
    @Override
    public List<CommodityComment> queryAllComments(Integer cid) {
        List<CommodityComment> commodityCommentList = commodityCommentMapper.queryAllComments(cid);
        return commodityCommentList;
    }
    /**
     *
     * @Author lzk
     * @Description 计算购物车数量
     * @date 2023/4/7 16:40
     * Return java.util.List<com.zhuiYun.project.api.appletshoppingcart.entity.AppletShoppingCartEntity>
     */
    @Override
    public Integer calculateTheNumberOfShoppingCarts(Integer userId) {
        Integer appletShoppingCartEntityList = appletShoppingCartMapper.calculateTheNumberOfShoppingCarts(userId);
        return appletShoppingCartEntityList;
    }
    /**
     *
     * @Author lzk
     * @Description 根据cid查询秒杀和商品信息
     * @date 2023/4/9 19:19
     * Return java.util.List<com.zhuiYun.project.api.seckill.entity.SeckillDto>
     * @param cid
     */
    @Override
    public SeckillDto getSeckillListByCid(Integer cid) {
        SeckillDto seckillDtoList = seckillDtoMapper.getSeckillListByCid(cid);
        return seckillDtoList;
    }
}
